package org.javaforever.gatescore.vue;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.javaforever.gatescore.core.Statement;
import org.javaforever.gatescore.core.StatementList;
import org.javaforever.gatescore.core.Writeable;
import org.javaforever.gatescore.core.WriteableUtil;

public class VueIndexRouterGenerator implements Comparable<VueIndexRouterGenerator>,Cloneable,Serializable{
	private static final long serialVersionUID = 7484443893496710836L;
	protected String standardName = "Index";
	protected boolean hasAuth = false;
	@Override
	public int compareTo(VueIndexRouterGenerator o) {
		return this.standardName.compareTo(o.getStandardName());
	}
	public String getStandardName() {
		return standardName;
	}
	public String getFileName() {
		return "index.js";
	}

	public StatementList generateStatementList() throws Exception{
		List<Writeable> sList = new ArrayList<Writeable>();
		sList.add(new Statement(1000L,0,"import Vue from 'vue'"));
		sList.add(new Statement(2000L,0,"import Router from 'vue-router'"));
		sList.add(new Statement(3000L,0,""));
		sList.add(new Statement(4000L,0,"Vue.use(Router)"));
		sList.add(new Statement(5000L,0,""));
		sList.add(new Statement(6000L,0,"/* Layout */"));
		sList.add(new Statement(7000L,0,"import Layout from '@/views/layout/Layout'"));
		sList.add(new Statement(8000L,0,""));
		sList.add(new Statement(9000L,0,"/* Router Modules */"));
		sList.add(new Statement(10000L,0,"import pagesRouter from './modules/pages'"));
		sList.add(new Statement(11000L,0,""));
		sList.add(new Statement(12000L,0,"/** note: sub-menu only appear when children.length>=1"));
		sList.add(new Statement(13000L,0,"*  detail see  https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html"));
		sList.add(new Statement(14000L,0,"**/"));
		sList.add(new Statement(15000L,0,""));
		sList.add(new Statement(16000L,0,"/**"));
		sList.add(new Statement(17000L,0,"* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)"));
		sList.add(new Statement(18000L,0,"* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length"));
		sList.add(new Statement(19000L,0,"*                                if not set alwaysShow, only more than one route under the children"));
		sList.add(new Statement(20000L,0,"*                                it will becomes nested mode, otherwise not show the root menu"));
		sList.add(new Statement(21000L,0,"* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb"));
		sList.add(new Statement(22000L,0,"* name:'router-name'             the name is used by <keep-alive> (must set!!!)"));
		sList.add(new Statement(23000L,0,"* meta : {"));
		sList.add(new Statement(24000L,1,"roles: ['admin','editor']    will control the page roles (you can set multiple roles)"));
		sList.add(new Statement(25000L,1,"title: 'title'               the name show in sub-menu and breadcrumb (recommend set)"));
		sList.add(new Statement(26000L,1,"icon: 'svg-name'             the icon show in the sidebar"));
		sList.add(new Statement(27000L,1,"noCache: true                if true, the page will no be cached(default is false)"));
		sList.add(new Statement(28000L,1,"breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)"));
		sList.add(new Statement(29000L,1,"affix: true                  if true, the tag will affix in the tags-view"));
		sList.add(new Statement(30000L,0,"}"));
		sList.add(new Statement(31000L,0,"**/"));
		sList.add(new Statement(32000L,0,"export const constantRouterMap = ["));
		sList.add(new Statement(33000L,1,"{"));
		sList.add(new Statement(34000L,2,"path: '/redirect',"));
		sList.add(new Statement(35000L,2,"component: Layout,"));
		sList.add(new Statement(36000L,2,"hidden: true,"));
		sList.add(new Statement(37000L,2,"children: ["));
		sList.add(new Statement(38000L,3,"{"));
		sList.add(new Statement(39000L,4,"path: '/redirect/:path*',"));
		sList.add(new Statement(40000L,4,"component: () => import('@/views/redirect/index')"));
		sList.add(new Statement(41000L,3,"}"));
		sList.add(new Statement(42000L,2,"]"));
		sList.add(new Statement(43000L,1,"},"));
		sList.add(new Statement(44000L,1,"{"));
		sList.add(new Statement(45000L,2,"path: '/login',"));
		sList.add(new Statement(46000L,2,"component: () => import('@/views/login/index'),"));
		sList.add(new Statement(47000L,2,"hidden: true"));
		sList.add(new Statement(48000L,1,"},"));
		if (this.hasAuth) {
			sList.add(new Statement(49000L,1,"{"));
			sList.add(new Statement(50000L,2,"path: '/register',"));
			sList.add(new Statement(51000L,2,"component: () => import('@/views/login/register'),"));
			sList.add(new Statement(52000L,2,"hidden: true"));
			sList.add(new Statement(53000L,1,"},"));
		}
		sList.add(new Statement(54000L,1,"{"));
		sList.add(new Statement(55000L,2,"path: '/auth-redirect',"));
		sList.add(new Statement(56000L,2,"component: () => import('@/views/login/authredirect'),"));
		sList.add(new Statement(57000L,2,"hidden: true"));
		sList.add(new Statement(58000L,1,"},"));
		sList.add(new Statement(59000L,1,"{"));
		sList.add(new Statement(60000L,2,"path: '/404',"));
		sList.add(new Statement(61000L,2,"component: () => import('@/views/errorPage/404'),"));
		sList.add(new Statement(62000L,2,"hidden: true"));
		sList.add(new Statement(63000L,1,"},"));
		sList.add(new Statement(64000L,1,"{"));
		sList.add(new Statement(65000L,2,"path: '/401',"));
		sList.add(new Statement(66000L,2,"component: () => import('@/views/errorPage/401'),"));
		sList.add(new Statement(67000L,2,"hidden: true"));
		sList.add(new Statement(68000L,1,"}"));
		sList.add(new Statement(69000L,0,"]"));
		sList.add(new Statement(70000L,0,""));
		sList.add(new Statement(71000L,0,"export default new Router({"));
		sList.add(new Statement(72000L,1,"// mode: 'history', // require service support"));
		sList.add(new Statement(73000L,1,"scrollBehavior: () => ({ y: 0 }),"));
		sList.add(new Statement(74000L,1,"routes: constantRouterMap"));
		sList.add(new Statement(75000L,0,"})"));
		sList.add(new Statement(76000L,0,""));
		sList.add(new Statement(77000L,0,"export const asyncRouterMap = ["));
		sList.add(new Statement(78000L,1,"/** When your routing table is too long, you can split it into small modules**/"));
		sList.add(new Statement(79000L,1,"pagesRouter,"));
		sList.add(new Statement(80000L,0,""));
		
		sList.add(new Statement(80100L,1,"{"));
		sList.add(new Statement(80200L,2,"path: '/static/',"));
		sList.add(new Statement(80300L,2,"component: Layout,"));
		sList.add(new Statement(80400L,2,"redirect: 'noredirect',"));
		sList.add(new Statement(80500L,2,"name: 'Static'"));
		sList.add(new Statement(80600L,1,"},"));
		
		sList.add(new Statement(81000L,1,"{"));
		sList.add(new Statement(82000L,2,"path: '/error',"));
		sList.add(new Statement(83000L,2,"component: Layout,"));
		sList.add(new Statement(84000L,2,"redirect: 'noredirect',"));
		sList.add(new Statement(85000L,2,"name: 'ErrorPages',"));
		sList.add(new Statement(86000L,2,"meta: {"));
		sList.add(new Statement(87000L,3,"title: 'errorPages',"));
		sList.add(new Statement(88000L,3,"icon: '404'"));
		sList.add(new Statement(89000L,2,"},"));
		sList.add(new Statement(90000L,2,"children: ["));
		sList.add(new Statement(91000L,3,"{"));
		sList.add(new Statement(92000L,4,"path: '401',"));
		sList.add(new Statement(93000L,4,"component: () => import('@/views/errorPage/401'),"));
		sList.add(new Statement(94000L,4,"name: 'Page401',"));
		sList.add(new Statement(95000L,4,"meta: { title: 'page401', noCache: true }"));
		sList.add(new Statement(96000L,3,"},"));
		sList.add(new Statement(97000L,3,"{"));
		sList.add(new Statement(98000L,4,"path: '404',"));
		sList.add(new Statement(99000L,4,"component: () => import('@/views/errorPage/404'),"));
		sList.add(new Statement(100000L,4,"name: 'Page404',"));
		sList.add(new Statement(101000L,4,"meta: { title: 'page404', noCache: true }"));
		sList.add(new Statement(102000L,3,"}"));
		sList.add(new Statement(103000L,2,"]"));
		sList.add(new Statement(104000L,1,"},"));
		sList.add(new Statement(105000L,0,""));
		sList.add(new Statement(106000L,1,"{"));
		sList.add(new Statement(107000L,2,"path: '/error-log',"));
		sList.add(new Statement(108000L,2,"component: Layout,"));
		sList.add(new Statement(109000L,2,"redirect: 'noredirect',"));
		sList.add(new Statement(110000L,2,"children: ["));
		sList.add(new Statement(111000L,3,"{"));
		sList.add(new Statement(112000L,4,"path: 'log',"));
		sList.add(new Statement(113000L,4,"component: () => import('@/views/errorLog/index'),"));
		sList.add(new Statement(114000L,4,"name: 'ErrorLog',"));
		sList.add(new Statement(115000L,4,"meta: { title: 'errorLog', icon: 'bug' }"));
		sList.add(new Statement(116000L,3,"}"));
		sList.add(new Statement(117000L,2,"]"));
		sList.add(new Statement(118000L,1,"},"));
		sList.add(new Statement(119000L,0,""));
		sList.add(new Statement(120000L,1,"{"));
		sList.add(new Statement(121000L,2,"path: '/i18n',"));
		sList.add(new Statement(122000L,2,"component: Layout,"));
		sList.add(new Statement(123000L,2,"children: ["));
		sList.add(new Statement(124000L,3,"{"));
		sList.add(new Statement(125000L,4,"path: 'index',"));
		sList.add(new Statement(126000L,4,"component: () => import('@/views/i18n-demo/index'),"));
		sList.add(new Statement(127000L,4,"name: 'I18n',"));
		sList.add(new Statement(128000L,4,"meta: { title: 'i18n', icon: 'international' }"));
		sList.add(new Statement(129000L,3,"}"));
		sList.add(new Statement(130000L,2,"]"));
		sList.add(new Statement(131000L,1,"},"));
		sList.add(new Statement(132000L,0,""));
		sList.add(new Statement(133000L,1,"{ path: '*', redirect: '/index', hidden: false }"));
		sList.add(new Statement(134000L,0,"]"));
		return WriteableUtil.merge(sList);
	}
	
	public boolean isHasAuth() {
		return hasAuth;
	}
	
	public void setHasAuth(boolean hasAuth) {
		this.hasAuth = hasAuth;
	}
	
	public void setStandardName(String standardName) {
		this.standardName = standardName;
	}
}
